/*=============================================================================

  APPLICATION MANAGER MODULE

  FILE: UImgr.cpp
  
  DESCRIPTION

    Manager Module Definition

  EXTERNALIZED FUNCTIONS

    
  Copyright (c) DaeSung Engineering Inc. All rights reserved.

=============================================================================*/
/*=============================================================================

                             EDIT HISTORY

  ---------  -------  -------------------------------------------------------
    when       who     what, where, why
  ---------  -------  -------------------------------------------------------
   06/28/03   nso4th   Version 0.1

=============================================================================*/

/*=============================================================================
  HEADER INCLUSION
=============================================================================*/
#include <UImgr_MOD.h>

/*=============================================================================
  LOCALIZED FUNCTION DEFINITION
=============================================================================*/
// UI
extern boolean ui_event_proc(dword type, dword event, dword wp, dword lp);

// Manager
extern boolean sysmgr_event_proc(dword event, dword wp, dword lp);
extern boolean iomgr_event_proc(dword event, dword wp, dword lp);

// Device
extern boolean io_event_proc(dword event, dword wp, dword lp);
extern boolean aio_event_proc(dword event, dword wp, dword lp);
extern boolean mot_event_proc(dword event, dword wp, dword lp);
extern boolean fg_event_proc(dword event, dword wp, dword lp);
extern boolean cam_event_proc(dword event, dword wp, dword lp);

// Module
extern boolean area_event_proc(dword event, dword wp, dword lp);

/*=============================================================================
  UI EVENT HANDLER
=============================================================================*/
dword UImgr::Event_Handler(dword dwType, dword dwEvent, dword wParam, dword lParam)
{	
	if(Event_PreProc(dwType, dwEvent, wParam, lParam) == TRUE)
		return	TRUE;

	// Final event processing
	return	(dword)ui_event_proc(dwType, dwEvent, wParam, lParam);
}

dword UImgr::Event_PreProc(dword dwType, dword dwEvent, dword wParam, dword lParam)
{
	// State Monitoring
	if(IS_STATE_EVENT(dwType))
	{
		if((m_monLock == FALSE) && (m_reqLock == FALSE))
		{
			MON_STATE();
		}
		return	TRUE;
	}
	
	// Block the internal event (Command, State event)
	if(IS_CMD_EVENT(dwType))
	{
		Command_Handler(dwEvent, wParam, lParam);
		return	TRUE;
	}
	
	switch(dwType)
	{
	// Manager
	case SYS_MGR:
		return	sysmgr_event_proc(dwEvent, wParam, lParam);
		
	case IO_MGR:
		return	iomgr_event_proc(dwEvent, wParam, lParam);

	// Module
	case AREA_MOD:
		return	area_event_proc(dwEvent, wParam, lParam);
		
	// Device
	case HIO_DEV:
		return	io_event_proc(dwEvent, wParam, lParam);

	case HAIO_DEV:
		return	aio_event_proc(dwEvent, wParam, lParam);

	case HMOT_DEV:
		return	mot_event_proc(dwEvent, wParam, lParam);
		
	case HFG_DEV:
		return	fg_event_proc(dwEvent, wParam, lParam);

	case HCAM_DEV:
		return	cam_event_proc(dwEvent, wParam, lParam);
	}

	return	FALSE;
}

/*--- END OF UImgr_EVT.CPP ---*/
